//
//  MineTableViewCell.m
//  KeleAppProject
//
//  Created by 周岑 on 2018/1/12.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "MineTableViewCell.h"
#import "CellTintModel.h"
@interface MineTableViewCell()

@property (nonatomic, strong) UIImageView *flagImageView;
@property (nonatomic, strong) UILabel *tintLabel;

@property (nonatomic, strong) UIImageView *moreImg;
@property (nonatomic, strong) UIView *lineView;

@end




@implementation MineTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self loadSubviewsOnMineViewCell];
    }
    return self;
}

// 加载视图
- (void)loadSubviewsOnMineViewCell{
    
    [self.contentView addSubview:self.flagImageView];
    [self.contentView addSubview:self.tintLabel];
    [self.contentView addSubview:self.dataLabel];
    [self.contentView addSubview:self.moreImg];
    [self.contentView addSubview:self.lineView];
    [self addConstrainsOnMineView];
    
}

// constrains
- (void)addConstrainsOnMineView{
    [self.flagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15*WIDTH);
    }];
    [self.tintLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.flagImageView.mas_right).offset(18*WIDTH);
    }];
    [self.dataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
//        make.left.equalTo(self.tintLabel.mas_right);
        make.right.equalTo(self.contentView).offset(-33*WIDTH);
    }];
    [self.moreImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-15*WIDTH);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(15*WIDTH);
        make.height.mas_equalTo(1);
    }];
}

- (void)setModel:(CellTintModel *)model{
    self.flagImageView.image = [UIImage imageNamed:model.flagImgName];
    self.tintLabel.text = model.tint;
    self.dataLabel.text = model.data;
}

- (void)setIsHiddenLine:(BOOL)isHiddenLine{
    
    self.lineView.hidden = isHiddenLine;
   
}

//  lazyout
- (UIImageView *)flagImageView{
    if (!_flagImageView) {
        _flagImageView = [[UIImageView alloc]init];
        _flagImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _flagImageView;
}

- (UILabel *)tintLabel{
    if (!_tintLabel) {
        _tintLabel = [[UILabel alloc]init];
        _tintLabel.textColor = KLColor_B6;
        _tintLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
    }
    return _tintLabel;
}

- (UILabel *)dataLabel{
    if (!_dataLabel) {
        _dataLabel = [[UILabel alloc]init];
        _dataLabel.textColor = KLColor_B7;
        _dataLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14*WIDTH];
        
    }
    return _dataLabel;
}

- (UIImageView *)moreImg{
    if (!_moreImg) {
        _moreImg = [[UIImageView alloc]init];
        _moreImg.contentMode = UIViewContentModeScaleAspectFit;
        _moreImg.image = [UIImage imageNamed:@"info_icon_into"];
    }
    return _moreImg;
}

- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = KLColor_B3;
        _lineView.hidden = YES;
    }
    return _lineView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    NSLog(@"哈哈哈哈");
    // Configure the view for the selected state
}

@end
